﻿<!doctype html>
<!--[if IE 7 ]>    <html lang="en-gb" class="isie ie7 oldie no-js"> <![endif]-->
<!--[if IE 8 ]>    <html lang="en-gb" class="isie ie8 oldie no-js"> <![endif]-->
<!--[if IE 9 ]>    <html lang="en-gb" class="isie ie9 no-js"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!-->
<html lang="en-gb" class="no-js">
<!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <!--[if lt IE 9]>
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <![endif]-->
    <title>优办公管理信息系统</title>
    {% load staticfiles %}
    <meta property="og:site_name" content="西安力啸网络科技有限公司" />
    <meta property="og:title" content="科技赋能未来" />
    <meta property="og:description" content=" 洞察 - 聚焦 - 创新" />
    <meta property="og:type" content="website" />
    <meta property="og:locale" content="zh_SG" />
    <meta name="twitter:card" content="summary" />
    <meta name="twitter:title" content="西安力啸网络科技有限公司" />
    <meta name="twitter:description" content="科技赋能未来" />
    <!--[if lt IE 9]>
            <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
    <!--[if lte IE 8]>
            <script type="text/javascript" src="http://explorercanvas.googlecode.com/svn/trunk/excanvas.js"></script>
        <![endif]-->
    <link rel="stylesheet" type="text/css" href="{% static 'online/css/bootstrap.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'online/css/styles.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'online/css/bootstrap-table.min.css' %}" />
    <link rel="stylesheet" type="text/css" href="{% static 'online/css/common-style.css' %}" />

    <link rel="stylesheet" type="text/css" href="{% static 'online/css/webuploader.css' %}" />

    <script src="{% static 'online/js/jquery-1.10.2.min.js' %}"></script>
    <script src="{% static 'online/laydate/laydate.js' %}"></script>
    <script src="{% static 'online/js/webuploader.js' %}"></script>

    <style>
        .input-group {
            width: 100%;
        }

        .input-group-addon {
            width: 120px;
        }

        .selectpicker {
            width: 100%;
            height: 34px;
        }

        .wu-example_ {
            /* position: relative; */
            padding: 45px 15px 15px;
            margin: 15px 0;
            background-color: #fafafa;
            box-shadow: inset 0 3px 6px rgba(0, 0, 0, .05);
            border-color: #e5e5e5 #eee #eee;
            border-style: solid;
            border-width: 1px 0;
        }

        .wu-example {
            padding-left: 10px;
        }

        #picker {
            float: left;
        }

        #ctlBtn {
            height: 33px;
            margin-left: 4px;
        }

        #picker2 {
            float: left;
        }

        #ctlBtn2 {
            height: 33px;
            margin-left: 4px;
        }

        .uploadcss {
            width: 86px;
            height: 40px;
        }
    </style>
</head>

<body>

    <header class="header">
        <div class="container">
            <nav class="navbar navbar-inverse" role="navigation">
                <div class="navbar-header">
                    <button type="button" id="nav-toggle" class="navbar-toggle" data-toggle="collapse" data-target="#main-nav"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button>

                    <a href="#" class="navbar-brand scroll-top logo"><b><i><img src="{% static 'online/images/logo_big.png' %}" /></i></b></a>
                </div>
                <!--/.navbar-header-->
                <div id="main-nav" class="collapse navbar-collapse" style="position:relative;">
                    <ul class="nav navbar-nav" id="mainNav">
                        <li class="" id="firstLink"><a href="/online/index/" class="scroll-link">首页</a></li>
                        <li class="" id="firstLink"><a href="/online/rule/" class="scroll-link">规章制度</a></li>
                        <li class="" id="firstLink"><a href="/online/vacation/" class="scroll-link">请假管理</a></li>
                        <!--<li><a href="services.html" class="scroll-link">报销系统</a></li>-->

                    </ul>

                    <div type="" id="nav-toggle" class="navbar-toggle" data-toggle="" style="display:block;" data-target="#divprofile">
                        <!--onclick="profile()"-->
                        <img src="{% static 'online/images/profile2.png' %}" style="width:46px;height:44px;" />
                        <span style="color: #787878;font-weight: bold;font-size: 1.1em;" id="usernamespan">loading...</span>&nbsp;&nbsp;
                        <span style="color: #787878;font-weight: bold;font-size: 1.1em;cursor:pointer;" onclick="logout()">退出</span>
                        <!--<img src="{% static 'online/images/downdont.png' %}" id="profileimg" style="margin-left:10px;" />-->
                    </div>
                    <div style="" class="downprofilediv" id="divprofile">
                        <h5>个人信息</h5>
                        <h5>修改密码</h5>
                    </div>

                </div>
                <!--/.navbar-collapse-->
            </nav>
            <!--/.navbar-->
        </div>
        <!--/.container-->
    </header>


    <div class="panel-body" style="margin-top:8px;">
        <!-- Table -->
        <div id="divrole" style="display:none;"></div>
        <table id="table"></table>
    </div>

    <footer class="footer">Copyright © 2018 西安力啸网络科技有限公司 版权所有 </footer>

    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">添加用户</h4>
                </div>
                <div class="modal-body">
                    <div id="myAlert" class="alert alert-success hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>提交成功！</strong>
                    </div>

                    <div id="myAlerterror" class="alert alert-warning hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>提交失败，请稍后重试！</strong>
                    </div>

                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">姓名</span>
                                    <input type="text" id="username" name="username" class="form-control" placeholder="请输入" aria-describedby="basic-addon1">
                                </div>
                            </div>
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">密码</span>
                                    <input type="password" id="userpwd" autocomplete="new-password" name="userpwd" class="form-control" placeholder="请输入,密码长度最少6位" aria-describedby="basic-addon1">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">邮箱</span>
                                    <input type="text" id="usermail" name="usermail" class="form-control" placeholder="请输入" aria-describedby="basic-addon1">
                                </div>
                            </div>

                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">所在部门</span>
                                    <select class="selectpicker" id="selectdep" name="selectdep" data-style="btn-info">
                                        <option value="1">软件研发部</option>
                                        <option value="2">行政人事部</option>
                                        <option value="3">财务部</option>
                                        <option value="4">市场销售部</option>
                                        <option value="5">系统管理</option>

                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="row">

                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">入职时间</span>
                                    <input type="text" id="entrydate" name="entrydate" class="form-control" placeholder="请选择" aria-describedby="basic-addon1">
                                </div>
                            </div>

                        </div>
                        <!--<div class="row" style="margin-top:10px;">
                            <div class="col-md-2 col-md-offset-10 margin-top-8">
                                <button class="btn btn-primary pull-right" id="submitbtn">Submit</button>
                            </div>
                        </div>-->

                        <div class="row">
                            <div class="col-md-12 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">个人简历</span>

                                    <div>

                                        <div id="uploader" class="wu-example">
                                            <!--用来存放文件信息-->
                                            <div id="thelist" class="uploader-list"></div>
                                            <div class="btns">
                                                <div id="picker">选择文件</div>
                                                <button id="ctlBtn" class="btn btn-default">开始上传</button>
                                            </div>
                                        </div>

                                    </div>
                                    <input type="hidden" id="resumefiles" name="resumefiles">

                                    <script>
                                        var uploader = WebUploader.create({
                                            swf: '/static/online/js/Uploader.swf',
                                            server: '/online/upload_ajax/',
                                            pick: '#picker',
                                            accept: {
                                                title: 'document',
                                                extensions: 'doc,docx,pdf',
                                                mimeTypes: 'document/*'
                                            },
                                            resize: false
                                        });

                                        $("#ctlBtn").click(function () {
                                            uploader.upload();
                                        });
                                        uploader.on('fileQueued', function (file) {
                                            $('#thelist').append('<div id="' + file.id + '" class="item">' +
                                                '<h5 class="info">' + file.name + '</h5>' +
                                                '<p class="state">等待上传...</p>' +
                                                '</div>');
                                        });

                                        // 文件上传过程中创建进度条实时显示。
                                        uploader.on('uploadProgress', function (file, percentage) {
                                            var $li = $('#' + file.id),
                                                $percent = $li.find('.progress span');
                                            // 避免重复创建
                                            if (!$percent.length) {
                                                $percent = $('<p class="progress"><span></span></p>').appendTo($li).find('span');
                                            }
                                            $percent.css('width', percentage * 100 + '%');
                                        });

                                        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                                        uploader.on('uploadSuccess', function (file, response) {
                                            $('#' + file.id).addClass('upload-state-done');
                                            if (response.success == '1') {
                                                $('#resumefiles').val(response.newfilename);
                                                $('#thelist').html('<div id="' + file.id + '" class="item">' +
                                                    '<h5 class="info">' + file.name + '</h5>' +
                                                    '<p class="state">上传成功</p>' +
                                                    '</div>');
                                            }
                                        });

                                        // 文件上传失败，显示上传出错。
                                        uploader.on('uploadError', function (file) {
                                            //var $li = $('#' + file.id),
                                            //    $error = $li.find('div.error');

                                            //// 避免重复创建
                                            //if (!$error.length) {
                                            //    $error = $('<div class="error"></div>').appendTo($li);
                                            //}
                                            //$error.text('上传失败');
                                            $('#thelist').html('<div id="' + file.id + '" class="item">' +
                                                '<h5 class="info">' + file.name + '</h5>' +
                                                '<p class="state">上传失败</p>' +
                                                '</div>');
                                        });

                                        // 完成上传完了，成功或者失败，先删除进度条。
                                        uploader.on('uploadComplete', function (file) {
                                            $('#' + file.id).find('.progress').remove();
                                        });

                                    </script>
                                </div>
                            </div>

                        </div>


                    </div>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 取消 </button>
                    <button type="button" class="btn btn-primary" id="submitbtn"> 提交 </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>


    <div class="modal fade" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">编辑用户</h4>
                </div>
                <div class="modal-body">
                    <div id="myAlert2" class="alert alert-success hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>提交成功！</strong>
                    </div>

                    <div id="myAlerterror2" class="alert alert-warning hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>提交失败，请稍后重试！</strong>
                    </div>

                    <div class="panel-body">
                        <div class="row">
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">姓名</span>
                                    <input type="text" id="username2" name="username2" class="form-control" placeholder="请输入" aria-describedby="basic-addon1">
                                </div>
                            </div>
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">密码</span>
                                    <input type="password" id="userpwd2" autocomplete="new-password" name="userpwd2" class="form-control" placeholder="请输入,密码长度最少6位" aria-describedby="basic-addon1">
                                </div>
                            </div>
                        </div>
                        <div class="row">
                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">邮箱</span>
                                    <input type="text" id="usermail2" name="usermail2" class="form-control" placeholder="请输入" aria-describedby="basic-addon1">
                                </div>
                            </div>

                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">所在部门</span>
                                    <select class="selectpicker" id="selectdep2" name="selectdep2" data-style="btn-info">
                                        <option value="1">软件研发部</option>
                                        <option value="2">行政人事部</option>
                                        <option value="3">财务部</option>
                                        <option value="4">市场销售部</option>
                                        <option value="5">系统管理</option>

                                    </select>
                                </div>
                            </div>

                        </div>

                        <div class="row">

                            <div class="col-md-6 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">入职时间</span>
                                    <input type="text" id="entrydate2" name="entrydate2" class="form-control" placeholder="请选择" aria-describedby="basic-addon1">
                                </div>
                            </div>


                        </div>
                        <!--<div class="row" style="margin-top:10px;">
                            <div class="col-md-2 col-md-offset-10 margin-top-8">
                                <button class="btn btn-primary pull-right" id="submitbtn">Submit</button>
                            </div>
                        </div>-->
                        <div class="row">

                            <div class="col-md-12 margin-top-8">
                                <div class="input-group">
                                    <span class="input-group-addon" id="">个人简历</span>

                                    <div>

                                        <div id="uploader2" class="wu-example">
                                            <!--用来存放文件信息-->
                                            <div id="thelist2" class="uploader-list"></div>
                                            <div class="btns">
                                                <div id="picker2">选择文件</div>
                                                <button id="ctlBtn2" class="btn btn-default">开始上传</button>
                                            </div>
                                        </div>

                                    </div>
                                    <input type="hidden" id="resumefiles2" name="resumefiles2">

                                    <script>
                                        var uploader2 = WebUploader.create({
                                            swf: '/static/online/js/Uploader.swf',
                                            server: '/online/upload_ajax/',
                                            pick: '#picker2',
                                            accept: {
                                                title: 'document',
                                                extensions: 'doc,docx,pdf',
                                                mimeTypes: 'document/*'
                                            },
                                            resize: false
                                        });

                                        $("#ctlBtn2").click(function () {
                                            uploader2.upload();
                                        });
                                        uploader2.on('fileQueued', function (file) {
                                            $('#thelist2').append('<div id="' + file.id + '" class="item">' +
                                                '<h5 class="info">' + file.name + '</h5>' +
                                                '<p class="state">等待上传...</p>' +
                                                '</div>');
                                        });

                                        // 文件上传过程中创建进度条实时显示。
                                        uploader2.on('uploadProgress', function (file, percentage) {
                                            var $li = $('#' + file.id),
                                                $percent = $li.find('.progress span');
                                            // 避免重复创建
                                            if (!$percent.length) {
                                                $percent = $('<p class="progress"><span></span></p>').appendTo($li).find('span');
                                            }
                                            $percent.css('width', percentage * 100 + '%');
                                        });

                                        // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                                        uploader2.on('uploadSuccess', function (file, response) {
                                            $('#' + file.id).addClass('upload-state-done');
                                            if (response.success == '1') {
                                                $('#resumefiles2').val(response.newfilename);
                                                $('#thelist2').html('<div id="' + file.id + '" class="item">' +
                                                    '<h5 class="info">' + file.name + '</h5>' +
                                                    '<p class="state">上传成功</p>' +
                                                    '</div>');
                                            }
                                        });

                                        // 文件上传失败，显示上传出错。
                                        uploader2.on('uploadError', function (file) {
                                            //var $li = $('#' + file.id),
                                            //    $error = $li.find('div.error');

                                            //// 避免重复创建
                                            //if (!$error.length) {
                                            //    $error = $('<div class="error"></div>').appendTo($li);
                                            //}
                                            //$error.text('上传失败');
                                            $('#thelist2').html('<div id="' + file.id + '" class="item">' +
                                                '<h5 class="info">' + file.name + '</h5>' +
                                                '<p class="state">上传失败</p>' +
                                                '</div>');
                                        });

                                        // 完成上传完了，成功或者失败，先删除进度条。
                                        uploader2.on('uploadComplete', function (file) {
                                            $('#' + file.id).find('.progress').remove();
                                        });

                                    </script>
                                </div>
                            </div>

                        </div>


                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 取消 </button>
                    <button type="button" class="btn btn-primary" onclick="editsubmit()" id="submitbtn2"> 提交 </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <div class="modal fade" id="myModaldel" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">删除选中用户</h4>
                </div>
                <div class="modal-body">
                    <div id="myAlert" class="alert alert-success hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>删除成功！</strong>
                    </div>

                    <div id="myAlerterror" class="alert alert-warning hidden" style="">
                        <!--<a href="#" class="close" data-dismiss="alert">&times;</a>-->
                        <strong>删除失败，请稍后重试！</strong>
                    </div>

                    <div class="panel-body">
                        <div class="row">
                            <h5>您确定要删除此信息吗 ？</h5>
                        </div>

                    </div>

                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal"> 取消 </button>
                    <button type="button" class="btn btn-primary" id="delbtn" onclick="deluser()"> 确定 </button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>

    <script src="{% static 'online/js/bootstrap.min.js' %}"></script>
    <script src="{% static 'online/js/bootstrap-table.min.js' %}"></script>
    <script src="{% static 'online/js/bootstrap-table-locale-all.min.js' %}"></script>
    <script src="{% static 'online/js/user.js' %}"></script>
    <!-- Bootstrap table extensions -->
    <!--
    <script src="js/bootstrap-table-export.js"></script>
    <script src="js/table-export/tableExport-bootstrap-table/tableExport.js"></script>
    <script src="js/common-script.js"></script>
    -->
    <!-- Business script -->
    <script src="{% static 'online/js/tableuser.js' %}"></script>
    <script>
        $(document).ready(function () {
            setTimeout(function () { $('.webuploader-pick').next().attr('style', 'width:86px;height:40px;position: absolute;top: 0px;left: 0px;'); $($('.webuploader-pick')[1]).next().attr('style', 'width:86px;height:40px;position: absolute;top: 0px;left: 0px;'); }, 2000);
        });
        Date.prototype.addDays = function (day, number) {
            var adjustDate = new Date(day + 24 * 60 * 60 * 1000 * 30 * number)
            //alert("Date" + adjustDate.getFullYear() + "-" + adjustDate.getMonth() + "-" + adjustDate.getDate());
            return adjustDate;
        }
        Date.prototype.Format = function (fmt) {
            var o = {
                "M+": this.getMonth() + 1,
                "d+": this.getDate(),
                "h+": this.getHours(),
                "m+": this.getMinutes(),
                "s+": this.getSeconds(),
                "q+": Math.floor((this.getMonth() + 3) / 3),
                "S": this.getMilliseconds() //??
            };
            if (/(y+)/.test(fmt))
                fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
            for (var k in o)
                if (new RegExp("(" + k + ")").test(fmt))
                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
            return fmt;
        }

        Date.prototype.addDays2 = function (d) {
            this.setDate(this.getDate() + d);
            return this.Format('yyyy-MM-dd');
        };
        laydate.render({
            elem: '#entrydate',
            lang: 'zh',
            done: function (value, date, endDate) {
                if (value && value.length > 0) {
                    $('#vac_date').attr('style', 'border:1px solid #ccc;');
                    var curDate = new Date(value);
                    $('#vac_enddate').val(curDate.addDays2(parseFloat($('#vac_interval').val())));
                } else {
                    $('#vac_enddate').val('');
                }
            }
        });

        $("#submitbtn").click(function () {
            var uname = $('#username');
            var upwd = $('#userpwd');
            var umail = $('#usermail');
            //var files = $('#files');
            var entdate = $('#entrydate');
            var utype = $('#selectdep');
            if (uname.val().length < 1) {
                uname.attr('style', 'border:1px solid red;');
                uname.focus();
                return;
            }
            if (upwd.val().length < 5) {
                upwd.attr('style', 'border:1px solid red;');
                upwd.focus();
                return;
            }
            if (umail.val().length < 1) {
                umail.attr('style', 'border:1px solid red;');
                umail.focus();
                return;
            } else {
                var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
                if (!myreg.test(umail.val())) {
                    umail.attr('style', 'border:1px solid red;');
                    umail.focus();
                    return;
                }
            }
            if (entdate.val().length < 1) {
                entdate.attr('style', 'border:1px solid red;');
                return;
            }

            $.ajax({
                url: '/online/saveuser/',
                type: 'POST',
                dataType: 'json',
                headers: { "X-CSRFToken": getCookie('csrftoken') },
                data: {
                    username: uname.val(),
                    userpwd: upwd.val(),
                    usermail: umail.val(),
                    userresume: $('#resumefiles').val(),
                    entrydate: entdate.val(),
                    udept: utype.val(),
                    temp: utype.find("option:selected").text()
                },
                success: function (data) {
                    if (data && data.success == '1') {
                        $('#myAlert').removeClass('hidden');
                        cleartxt();
                        setTimeout(function () {
                            $('#myModal').modal('hide');
                            $('#myAlert').addClass('hidden');
                            reloaddata();
                        }, 1000);

                    } else {
                        $('#myAlerterror').removeClass('hidden');
                        setTimeout(function () {
                            $('#myAlerterror').addClass('hidden');
                        }, 1500);
                    }
                }
            })

        })

        function cleartxt() {
            $('#username').val('').attr('style', 'border:1px solid #ccc;');
            $('#userpwd').val('').attr('style', 'border:1px solid #ccc;');
            $('#usermail').val('').attr('style', 'border:1px solid #ccc;');
            $('#entrydate').val('').attr('style', 'border:1px solid #ccc;');
            $('#thelist').html('');//clear upload hoistory
        }
        function cleartxtedit() {
            $('#username2').val('').attr('style', 'border:1px solid #ccc;');
            $('#userpwd2').val('').attr('style', 'border:1px solid #ccc;');
            $('#usermail2').val('').attr('style', 'border:1px solid #ccc;');
            $('#entrydate2').val('').attr('style', 'border:1px solid #ccc;');
            $('#thelist2').html('');//clear upload hoistory
        }
        var gid = 0;
        function opendelconfirm() {
            if (selectrow != null && selectrow.id != null && selectrow.id > 0) {
                gid = selectrow.id;
                $("#myModaldel").modal("show");
            }
        }
        function deluser() {
            if (gid == 0) {
                alert("请选择要删除的项！");
                return;
            }
            $.ajax({
                url: '/online/deluser/',
                type: 'POST',
                dataType: 'json',
                headers: { "X-CSRFToken": getCookie('csrftoken') },
                data: {
                    id: gid
                },
                success: function (data) {
                    if (data && data.success == '1') {
                        $('#myModaldel').modal('hide');
                        reloaddata();
                    } else {
                        $('#myModaldel').modal('hide');
                        alert('删除失败，请稍后重试！');
                    }
                }
            })
        }

        function openeditconfirm() {
            if (selectrow != null && selectrow.id != null && selectrow.id > 0) {
                gid = selectrow.id;
                $("#myModaledit").modal("show");

                $('#username2').val(selectrow.username);
                //$('#userpwd2').val('');
                $('#usermail2').val(selectrow.useremail);
                $('#entrydate2').val(selectrow.entrydate);
                $('#selectdep2').val(selectrow.userdepartment);
                $('#thelist2').html('');//clear upload hoistory

            }
        }

        function editsubmit() {
            if (selectrow == null || selectrow.id == null || selectrow.id < 1) {
                return;
            }
            var uname = $('#username2');
            var upwd = $('#userpwd2');
            var umail = $('#usermail2');
            //var files = $('#files');
            var entdate = $('#entrydate2');
            var utype = $('#selectdep2');
            if (uname.val().length < 1) {
                uname.attr('style', 'border:1px solid red;');
                return;
            }
            if (upwd.val().length < 5) {
                upwd.attr('style', 'border:1px solid red;');
                return;
            }
            if (umail.val().length < 1) {
                umail.attr('style', 'border:1px solid red;');
                return;
            } else {
                var myreg = /^([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+@([a-zA-Z0-9]+[_|\_|\.]?)*[a-zA-Z0-9]+\.[a-zA-Z]{2,3}$/;
                if (!myreg.test(umail.val())) {
                    umail.attr('style', 'border:1px solid red;');
                    umail.focus();
                    return;
                }
            }
            if (entdate.val().length < 1) {
                entdate.attr('style', 'border:1px solid red;');
                return;
            }

            $.ajax({
                url: '/online/edituser/',
                type: 'POST',
                dataType: 'json',
                headers: { "X-CSRFToken": getCookie('csrftoken') },
                data: {
                    username: uname.val(),
                    userpwd: upwd.val(),
                    usermail: umail.val(),
                    userresume: $('#resumefiles2').val(),
                    entrydate: entdate.val(),
                    udept: utype.val(),
                    temp: utype.find("option:selected").text(),
                    id: gid
                },
                success: function (data) {
                    if (data && data.success == '1') {
                        $('#myAlert2').removeClass('hidden');
                        cleartxtedit();
                        setTimeout(function () {
                            $('#myModaledit').modal('hide');
                            $('#myAlert2').addClass('hidden');
                            reloaddata();
                        }, 1000);

                    } else {
                        $('#myAlerterror2').removeClass('hidden');
                        setTimeout(function () {
                            $('#myAlerterror2').addClass('hidden');
                        }, 1500);
                    }
                }
            })
        }

    </script>
</body>

</html>
